<!DOCTYPE html>
<html lang="zh-hans">
<head>
  {% block title %}<title>图书馆管理系统</title>{% endblock %}
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
  {% load static %}
  <link rel="stylesheet" href="{% static 'css/styles.css' %}">
  {% block extra_css %}{% endblock %}
</head>
<body>
  <div class="container-fluid">
    <div class="row">
      <div class="col-sm-2 sidebar">
      {% block sidebar %}
        <div class="text-center py-4">
          <h3 class="text-white">图书馆</h3>
        </div>
        <ul class="sidebar-nav">
          <li><a href="{% url 'index' %}"><i class="fas fa-home me-2"></i>首页</a></li>
          <li><a href="{% url 'books' %}"><i class="fas fa-book me-2"></i>所有图书</a></li>
          <li><a href="{% url 'authors' %}"><i class="fas fa-user-pen me-2"></i>所有作者</a></li>
          <li><a href="{% url 'book-ranking' %}"><i class="fas fa-chart-line me-2"></i>排行榜</a></li>
          <li><a href="{% url 'recommend-books' %}"><i class="fas fa-thumbs-up me-2"></i>推荐书籍</a></li>
          
          {% if user.is_authenticated %}
            <hr>
            <li><i class="fas fa-user me-2"></i>欢迎, {{ user.get_username }}</li>
            <li><a href="{% url 'profile' %}"><i class="fas fa-id-card me-2"></i>个人资料</a></li>
            <li><a href="{% url 'my-borrowed' %}"><i class="fas fa-book-reader me-2"></i>我借的书</a></li>
            <li><a href="{% url 'logout' %}?next={{ request.path }}"><i class="fas fa-sign-out-alt me-2"></i>退出登录</a></li>
            {% if perms.catalog.can_mark_returned %}
              <hr>
              <li class="sidebar-title">工作人员</li>
              <li><a href="{% url 'all-borrowed' %}"><i class="fas fa-list me-2"></i>所有借出的书</a></li>
              <hr>
              <li class="sidebar-title">数据管理</li>
              <li><a href="{% url 'author-create' %}"><i class="fas fa-plus me-2"></i>添加作者</a></li>
              <li><a href="{% url 'book-create' %}"><i class="fas fa-plus me-2"></i>添加图书</a></li>
            {% endif %}
          {% else %}
            <hr>
            <li><a href="{% url 'login' %}?next={{ request.path }}"><i class="fas fa-sign-in-alt me-2"></i>登录</a></li>
            <li><a href="{% url 'register' %}"><i class="fas fa-user-plus me-2"></i>注册</a></li>
          {% endif %}
        </ul>
      {% endblock %}
      </div>
      <div class="col-sm-10 content-area">
        {% if messages %}
          {% for message in messages %}
            <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
              {{ message }}
              <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
          {% endfor %}
        {% endif %}
        
        {% block content %}{% endblock %}
        
        {% block pagination %}
          {% if is_paginated %}
            <div class="pagination">
              <span class="page-links">
                {% if page_obj.has_previous %}
                  <a href="{{ request.path }}?page={{ page_obj.previous_page_number }}">上一页</a>
                {% endif %}
                <span class="page-current">
                  第 {{ page_obj.number }} 页，共 {{ page_obj.paginator.num_pages }} 页
                </span>
                {% if page_obj.has_next %}
                  <a href="{{ request.path }}?page={{ page_obj.next_page_number }}">下一页</a>
                {% endif %}
              </span>
            </div>
          {% endif %}
        {% endblock %}
      </div>
    </div>
  </div>
  
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  {% block extra_js %}{% endblock %}
</body>
</html> 